<?
session_start();
if (!isset($_SESSION["sess_Username"])) { 
?>
  <script>
	alert('กรุณาทำการ Login เข้าระบบก่อน');
	</script>

	<meta http-equiv='refresh' content='0;URL=admin_login.php'>
<?
include "connectdb.php" ;
 } 
 ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"/><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ยินดีต้อนรับเข้าสู่ ระบบบริการสื่อมัลติมีเดียด้านการเกษตร</title>
<link rel="stylesheet" href="standard.css" type="text/css" />
<script>  
	function txtreset()
		{
		document.frmSearch.txtkeyword.value="";
		}
</script>
<script type="text/javascript">
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>

</head>

<body onLoad="MM_preloadImages('img/m_main2.jpg','img/m_register2.jpg','img/m_multimedia2.jpg','img/m_manual2.jpg','img/m_evaluate2.jpg','img/m_admin2.jpg','img/m_static2.jpg','img/m_topten2.jpg')">
<table width="1024" height="659" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#666600">
  <tr>
    <td height="215" align="center" valign="top" bgcolor="#CCCCCC"><table width="1024" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="170" background="img/headNew2.jpg" bgcolor="#FFFFFF">&nbsp;</td>
      </tr>
    </table>
        <table width="824" border="0" cellpadding="0" cellspacing="0" bordercolor="#FF0000">
          <tr>
            <td width="103" height="45" align="center"><a href="index.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image12','','img/m_main2.jpg',1)"><img src="img/m_main.jpg" name="Image12" width="115" height="45" border="0" id="Image12" /></a></td>
            <td width="103" align="right"><a href="user_register.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image13','','img/m_register2.jpg',1)"><img src="img/m_register.jpg" name="Image13" width="115" height="45" border="0" id="Image13" /></a></td>
            <td width="103" align="right"><a href="vdo_list.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image14','','img/m_multimedia2.jpg',1)"><img 
src="img/m_multimedia.jpg" name="Image14" width="117" height="45" border="0" id="Image14" /></a></td>
            <td width="103"><a href="vdo_top10.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image11','','img/m_topten2.jpg',1)"><img 
src="img/m_topten.jpg" name="Image11" width="115" height="45" border="0" id="Image11" /></a></td>
            <td width="103"><a href="admin_report_search.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image10','','img/m_static2.jpg',1)"><img 
src="img/m_static.jpg" name="Image10" width="215" height="45" border="0" id="Image10" /></a></td>
            <td width="103"><a href="manual.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image9','','img/m_manual2.jpg',1)"><img src="img/m_manual.jpg" name="Image9" width="117" height="45" border="0" id="Image9" /></a></td>
            <td width="103"><a href="evaluate_overview.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image8','','img/m_evaluate2.jpg',1)"><img src="img/m_evaluate.jpg" name="Image8" width="115" height="45" border="0" id="Image8" /></a></td>
            <td width="103"><a href="admin_login.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image15','','img/m_admin2.jpg',1)"><img src="img/m_admin.jpg" name="Image15" width="115" height="45" border="0" id="Image15" /></a></td>
          </tr>
        </table></td>
  </tr>
  <tr>
    <td width="1024" height="66" align="center" valign="top" bgcolor="#FFFFFF"><table width="1024" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="25" height="25" background="img/tb/tb_left_top.jpg">&nbsp;</td>
        <td height="25" background="img/tb/tb_top.jpg">&nbsp;</td>
        <td width="25" height="25" background="img/tb/tb_right_top.jpg">&nbsp;</td>
      </tr>
      <tr>
        <td width="25" align="left" background="img/tb/tb_left.jpg">&nbsp;</td>
        <td align="center"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="30" align="left" bgcolor="#CCFF00" class="style7"><span class="scapmain style7">&nbsp;<img src="img/img05.gif" align="absbottom" /></span> รายการผู้ดูแลระบบ</td>
            <td align="right" bgcolor="#CCFF00" class="style7"><? if(isset($_SESSION["sess_Username"])){echo"<a href="."admin_logout.php"."><img src="."pic/logout(red)_icon.jpeg"." width='30' alt='ออกจากระบบ' border='0'/></a>";} ?></td>
          </tr>
          <tr>
            <td colspan="2" align="center" bgcolor="#FFFFFF"><table height="40" width="98%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td align="right" valign="middle"><p>
                      <form action="admin_add.php" name="frm_add" id="frm_add" onSubmit="">
                        <input type="submit" name="btn_add" id="btn_add" value="+ เพิ่มรายการผู้ดูแลระบบ" />
                      </form>
                    </p>                  </td>
                </tr>
              </table>
              <table width="98%" border="0" cellspacing="0" cellpadding="0">
              <form action="<?=$_SERVER['SCRIPT_NAME'];?>" method="post" name="frmSearch" id="frmSearch">
                <tr>
                  <td width="83%" height="40" align="center" valign="middle" bgcolor="#FFCC33"><span class="style18">&nbsp;&nbsp;
                        <select name="txtfield" id="txtfield">
                          <option value="1" <? if($_POST["txtfield"] == '1') echo"selected" ?>>ค้นหาตามรหัส</option>
                          <option value="2" <? if($_POST["txtfield"] == '2') echo"selected" ?>>ค้นหาตามชื่อ</option>
                          <option value="3" <? if($_POST["txtfield"] == '3') echo"selected" ?>>ค้นหาตามนามสกุล</option>
                          <option value="4" <? if($_POST["txtfield"] == '4') echo"selected" ?>>ค้นหาตาม E-Mail</option>
                        </select>
                    &nbsp;&nbsp;: :</span>&nbsp;&nbsp;
                    <input name="txtkeyword" type="text" id="txtkeyword" size="50" value="<?=$_POST["txtkeyword"];?>" />
                    <input type="button" name="button2" id="button2" value="ล้าง"  onclick="txtreset()"/>                  </td>
                  <td width="12%" align="center" valign="middle" bgcolor="#FFCC33"><!-- <p>
          <input name="cb_array[]" type="checkbox" value="รหัส" checked="checked" />&nbsp;<span class="style18">รหัส</span>&nbsp;&nbsp;
          <input name="cb_array[]" type="checkbox" value="ชื่อ" checked="checked" />&nbsp;<span class="style18">ชื่อ</span>&nbsp;&nbsp;
          <input name="cb_array[]" type="checkbox" value="นามสกุล" checked="checked" />&nbsp;<span class="style18">นามสกุล</span>&nbsp;&nbsp;
          <input name="cb_array[]" type="checkbox" value="E-Mail" checked="checked" />&nbsp;<span class="style18">E-Mail</span>&nbsp;&nbsp;          </p>-->
                      <input type="submit" name="button" id="button" value="ค้นหา" /></td>
                  <td width="5%" align="left" valign="middle" bgcolor="#FFCC33">&nbsp;</td>
                </tr>
              </form>
            </table>
            <table width="98%" height="267" border="0" cellpadding="0" cellspacing="0">
                      <tr>
                        <td align="center" valign="top">
                            <? 
include "connectdb.php" ;
$tb="ag_employee"; 

////ถ้าไม่เป็นค่าว่าง////
if($_POST["txtkeyword"] != "") 
{
		if($_POST["txtfield"]=="1"){
		$condition = " WHERE (emp_id LIKE '%".$_POST["txtkeyword"]."%') ";
		}
		else if($_POST["txtfield"]=="2"){
		$condition = " WHERE (emp_name LIKE '%".$_POST["txtkeyword"]."%') ";
		}
		else if($_POST["txtfield"]=="3"){
		$condition = " WHERE (emp_lname LIKE '%".$_POST["txtkeyword"]."%') ";
		}
		else if($_POST["txtfield"]=="4"){
		$condition = " WHERE (emp_email LIKE '%".$_POST["txtkeyword"]."%') ";
		}
}
////ถ้า่เป็นค่าว่าง////
else if ($_POST["txtkeyword"] == "")
{
	$condition = "";
}

mysql_select_db($dbname) or die("เลือกฐานขอมูลไมได"); /* ทําการเลือกฐานขอมูลกอน */ 
$sql="SELECT * FROM $tb $condition order by emp_id"; 
$db_query=mysql_db_query($dbname,$sql); 
$num_rows=mysql_num_rows($db_query); /* นับ Reccord ทีพบ */

                         
                            
                             ///////////////// วน loop แสดงข้อมูล //////////////////////
if($num_rows == '0'){
echo"<left><br><div align='center' class='style8'>ไม่พบข้อมูลที่ต้องการ</div></left>"; 
}else{
echo"<left><br><div align='center' class='style8'>จํานวน $num_rows รายการ</div></left>"; }
$a=0; 
$colorzero="#FFF2A4";
$colorone="#FEE86E";
$bgcolor="";

while($a < $num_rows) 
{ 
$result = mysql_fetch_array($db_query); 
$emp_id			=$result[emp_id]; 
$emp_name		=$result[emp_name]; 
$emp_lname		=$result[emp_lname]; 
$emp_position	=$result[emp_position]; 
$emp_tel		=$result[emp_tel]; 
$emp_email		=$result[emp_email]; 
$emp_pic		=$result[emp_pic]; 

if($emp_pic==""){
$emp_pic_word = "NO PHOTO";
}else $emp_pic_word = "<img src='$emp_pic' width='120' />";

if (($a % 2) == 0) {
$bgcolor=$colorzero;
}
else $bgcolor=$colorone;



?>
                            
                          <table width="75%" height="150" border="1" cellpadding="2" cellspacing="0" bordercolor="#E8AD35">
                              <tr>
                                <td width="120" rowspan="6" align="center" valign="middle" class="style24"><!--   <input type="image" name="imageField" id="imageField" src= "<?= $sess_Pic ?>" />-->
                               <p>     <?php echo "$emp_pic_word" ?> 
                               <br/> <a href="admin_delete.php?id=<?=$emp_id?>"><img src='pic/delete.gif' width='16' height='16' border='0' alt='ลบรายการผู้ดูแลระบบ' />
                                <input type="hidden" name="emp_id_old" id="emp_id_old"  value="<?=$emp_id?>"/></a>                                </p>                                </td>
                                <td width="173" height="25" align="left" bgcolor="#FEEE96" class="style24"><span class="style24">&nbsp;&nbsp;รหัสพนักงาน</span></td>
                                <td height="25" align="left" valign="middle" bgcolor="#FEEE96" class="style24"><span class="style24">&nbsp;&nbsp;
                                      <?=$emp_id?>
                                     
                                &nbsp;</span></td>
                            </tr>
                              <tr>
                                <td height="25" align="left" bgcolor="#FEEE96" class="style24"><span class="style24">&nbsp;&nbsp;ชื่อ</span></td>
                                <td height="25" align="left" valign="middle" bgcolor="#FEEE96" class="style24"><span class="style24">
                                  <label> &nbsp;&nbsp;
                                  <?=$emp_name?>
                                  </label>
                                </span></td>
                              </tr>
                              <tr>
                                <td height="25" align="left" bgcolor="#FEEE96" class="style24"><span class="style24">&nbsp;&nbsp;นามสกุล</span></td>
                                <td height="25" align="left" valign="middle" bgcolor="#FEEE96" class="style24"><span class="style24">&nbsp;&nbsp;
                                      <?=$emp_lname?>
                                </span></td>
                              </tr>
                              <tr>
                                <td height="25" align="left" bgcolor="#FEEE96" class="style24"><span class="style24">&nbsp;&nbsp;ตำแหน่ง</span></td>
                                <td height="25" align="left" valign="middle" bgcolor="#FEEE96" class="style24"><span class="style24">&nbsp;&nbsp;
                                      <?=$emp_position?>
                                </span></td>
                              </tr>
                              <tr>
                                <td height="25" align="left" bgcolor="#FEEE96" class="style24"><span class="style24">&nbsp;&nbsp;หมายเลขโทรศัพท์</span></td>
                                <td height="25" align="left" valign="middle" bgcolor="#FEEE96" class="style24"><span class="style24">&nbsp;&nbsp;
                                      <?=$emp_tel?>
                                </span></td>
                              </tr>
                              <tr>
                                <td height="25" align="left" bgcolor="#FEEE96" class="style24"><span class="style24">&nbsp;&nbsp;E-mail</span></td>
                                <td height="25" align="left" valign="middle" bgcolor="#FEEE96" class="style24"><span class="style24">&nbsp;&nbsp;
                                      <?=$emp_email?>
                                </span></td>
                              </tr>
                            </table>
                         
                            <? 
$a++; 
} 

mysql_close(); 
?>                        </td>
                      </tr>
                    </table>
                    <p>&nbsp;</p>              </td>
          </tr>
          <tr>
            <td height="25" colspan="2" bgcolor="#CCFF00">&nbsp;</td>
          </tr>
        </table></td>
        <td width="25" align="right" background="img/tb/tb_right.jpg">&nbsp;</td>
      </tr>
      <tr>
        <td width="25" height="25" background="img/tb/tb_left_foot.jpg">&nbsp;</td>
        <td height="25" background="img/tb/tb_foot.jpg">&nbsp;</td>
        <td width="25" height="25" background="img/tb/tb_right_foot.jpg">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td width="1024" align="center" valign="bottom"><table width="50%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="25">&nbsp;</td>
      </tr>
    </table>
        <table width="1024" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="50"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="25" height="25" background="img/tb/tb_left_top.jpg">&nbsp;</td>
                  <td background="img/tb/tb_top.jpg">&nbsp;</td>
                  <td width="25" height="25" background="img/tb/tb_right_top.jpg">&nbsp;</td>
                </tr>
                <tr>
                  <td width="25" align="left" background="img/tb/tb_left.jpg">&nbsp;</td>
                  <td height="25" align="center" valign="middle" bgcolor="#CCFF00"><table width="96%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td height="25" align="center"><strong>ศูนย์ความรู้ด้านการเกษตร สำนักหอสมุด มหาวิทยาลัยเกษตรศาสตร์</strong></td>
                      </tr>
                  </table></td>
                  <td width="25" align="right" background="img/tb/tb_right.jpg">&nbsp;</td>
                </tr>
                <tr>
                  <td width="25" height="25" background="img/tb/tb_left_foot.jpg">&nbsp;</td>
                  <td background="img/tb/tb_foot.jpg">&nbsp;</td>
                  <td width="25" height="25" background="img/tb/tb_right_foot.jpg">&nbsp;</td>
                </tr>
            </table></td>
          </tr>
      </table></td>
  </tr>
</table>
<p>&nbsp;</p>
</body>
</html>
